#ifndef __WEBPAGEQUERY_HPP__
#define __WEBPAGEQUERY_HPP__

//这个还要写文件路径，不太方便
/* #include "../include/cppjieba/Jieba.hpp" */
#include "../include/CppJieba.hpp"
#include "../include/PureWebPage.hpp"
#include <map>
#include <vector>
#include <unordered_map>
#include <set>

using WordSegmentation = CppJieba;
using std::vector;
using std::map;
using std::unordered_map;
using std::set;
using std::string;
using std::make_pair;

class WebPage;

class WebPageQuery
{
public:
    WebPageQuery();
    string doQuery(string & str);//该任务会转交给Searcher类去做
    void loadLibrary();//离线接口已经把下面三个库存好了，现在需要放到Query中备用
    vector<double> getQueryWordsWeightVector(vector<string> & queryWords);
    //搜索的信息需要经过jieba分词变成queryWords，再传入这个函数计算所查询词的权重
    bool executeQuery(const vector<string> & queryWords, vector<std::pair<int ,vector<double>>> &resultVec);

    string createJson(vector<int> & docIdVec, const vector<string> & queryWords);
    //涉及到json，先不做
    string returnNoAnswer();
private:
    WordSegmentation _jieba;
    map<int, PureWebPage> _pageLib;
    map<int, std::pair<int, int>> _offsetLib;
    unordered_map<string, set<std::pair<int, double>>> _invertIndexTable;
};

#endif
